package com.edu.exam.enums;

/**
 * 成绩审核操作类型枚举
 *
 * @author System
 * @version 1.0.0 */
public enum GradeAuditOperationType {
    /** 创建 */
    CREATE("CREATE", "创建"),
    /** 更新 */
    UPDATE("UPDATE", "更新"),
    /** 删除 */
    DELETE("DELETE", "删除"),
    /** 提交 */
    SUBMIT("SUBMIT", "提交"),
    /** 审批 */
    APPROVE("APPROVE", "审批"),
    /** 拒绝 */
    REJECT("REJECT", "拒绝"),
    /** 撤销 */
    CANCEL("CANCEL", "撤销"),
    /** 暂停 */
    SUSPEND("SUSPEND", "暂停"),
    /** 恢复 */
    RESUME("RESUME", "恢复"),
    /** 分配 */
    ASSIGN("ASSIGN", "分配"),
    /** 转交 */
    TRANSFER("TRANSFER", "转交"),
    /** 完成 */
    COMPLETE("COMPLETE", "完成"),
    /** 归档 */
    ARCHIVE("ARCHIVE", "归档");

    private final String code;
    private final String description;

    GradeAuditOperationType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static GradeAuditOperationType fromCode(String code) {
        if (code == null) {
            throw new IllegalArgumentException("Code cannot be null");
        }
        for (GradeAuditOperationType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown code: " + code);
    }

    public static GradeAuditOperationType fromDescription(String description) {
        if (description == null) {
            throw new IllegalArgumentException("Description cannot be null");
        }
        for (GradeAuditOperationType type : values()) {
            if (type.getDescription().equals(description)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}